import { ref }         from "vue"
import { defineStore } from "pinia"

export const useKeepAliveStore = defineStore("keepAlive", () => {
    let keepAliveComponentsName = ref([])
    
    function set(arr){
        keepAliveComponentsName.value = arr
    }
    
    function add(one){
        keepAliveComponentsName.value.push(one)
    }
    
    function del(name){
        const key = keepAliveComponentsName.value.indexOf(name)
        if(key !== -1){
            keepAliveComponentsName.value.splice(key, 1)
        }
    }
    
    return {
        keepAliveComponentsName,
        
        set,
        add,
        del,
    }
})
